package com.sit.jike.hrproject.controller;

import com.sit.jike.hrproject.bean.UserBean;
import jakarta.servlet.http.HttpSession;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/auth")
public class AuthController {
    @PostMapping("/login.do")
    public Map<String, Object> login(String userCode, String password) {
        if (StringUtils.isNotBlank(userCode)) {
            userCode = userCode.trim();
        }
        if (StringUtils.isNotBlank(password)) {
            password = password.trim();
        }

        // =====此处应该调用service进行用户名与密码的验证======
        UserBean user = new UserBean();
        user.setUserCode(userCode);
        user.setRealName("测试人员");
        // =========================

        Map<String, Object> map = new HashMap<String, Object>();
        map.put("result", "ok");
        map.put("data", user);
        return map;
    }
}
